/*
 * Copyright (C) 2011 Jesus Navalon i Pastor <jnavalon at redhermes dot net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * pn_TableCellRenderer.java
 *
 * Created on 10/07/2011, 16:54:14
 */
package kuasar.plugin.deployer.gui.classmod;

import java.awt.Component;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import kuasar.plugin.deployer.Config;

/**
 *
 * @author Jesus Navalon i Pastor <jnavalon at redhermes dot net>
 */
public class pn_TableCellRenderer extends javax.swing.JPanel implements javax.swing.tree.TreeCellRenderer { 
    
    /** Creates new form pn_TableCellRenderer */
    public pn_TableCellRenderer() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbl_Text = new javax.swing.JLabel();

        setOpaque(false);

        lbl_Text.setForeground(new java.awt.Color(204, 204, 204));
        lbl_Text.setIcon(new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/deployer/icons/folder16.png"))); // NOI18N
        lbl_Text.setText("<text>");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbl_Text, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbl_Text, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lbl_Text;
    // End of variables declaration//GEN-END:variables

    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        if(value==null){
            return this;
        }
        String[] data = (String[]) ((DefaultMutableTreeNode) value).getUserObject();
        if(data==null){
            return this;
        }
        lbl_Text.setText(data[1]);
        if(data[2]==null)
            lbl_Text.setIcon(new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/deployer/icons/warning16.png")));
        else{
            if(data[2].isEmpty()){
                lbl_Text.setIcon(new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/deployer/icons/folder16.png")));
            }else{
                if(data[3]==null){
                    lbl_Text.setIcon(new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/deployer/icons/computer16.png")));
                }else{
                    lbl_Text.setIcon(new javax.swing.ImageIcon(getClass().getResource(Config.VMicondir + "netlist/16" + data[3])));
                }
            }
        }
        return this;
    }
}
